import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GTextFormat } from "../../../../common/GTextFormat";
import { MsgManager } from "../../../manager/MsgManager";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { _value } from "../../../../../this/_value";
type int = number;
//class AuctionPricePannel
    
    export  class AuctionPricePannel extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(340, 190);
            this.title = Language.getString(90655);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._infoTxt = ObjCreate.createGTextField(Language.getString(90649), 105, 71, 200, 20, this, GlobalStyle.textFormat6);
            this._input = ObjCreate.createGTextInput(63, 100, 200, 20, this);
            this._input.addEventListener(flash.events.Event.CHANGE, this.onChange);
            this._input.restrict = "0-9";
            var loc1=new GTextFormat(null, null, 16777215);
            loc1.align = "center";
            this._input.setStyle("textFormat", loc1);
            this._input.text = this._value.toString();
            this._confirmBtn = ObjCreate.createGButton(Language.getString(90653), 82, 142, 40, 28, this, "Button", this.onClick);
            this._cancleBtn = ObjCreate.createGButton(Language.getString(90654), 185, 142, 40, 28, this, "Button", this.onClick);
            var loc2=ObjCreate.createGTextField(Language.getString(90677) + ":", 95, this._input.y + this._input.height + 3, 100, 20, this);
            loc2.autoSize = "left";
            this._lowPriceTxt = ObjCreate.createGTextField("--", 152, this._input.y + this._input.height + 3, 130, 20, this);
            return;
        }

        /* internal  */onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.currentTarget;
            switch (loc1) 
            {
                case this._confirmBtn:
                {
                    this.auction();
                    break;
                }
                case this._cancleBtn:
                {
                    this.hide();
                    break;
                }
            }
            return;
        }

        /* internal  */auction(): void
        {
            if (this._input.text.charAt(0) == "0" && this._input.text.length > 1) 
            {
                MsgManager.showRollTipsMsg(Language.getString(90657));
            }
            else if (this._value) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ToAuctionCity, {"price": _value, "x": this._data.x, "y": this._data.y}));
            }
            return;
        }

        protected onChange(arg1: Object /* flash.events.Event */): void
        {
            if (!(this._input.text.charAt(0) == "0") || this._input.text.charAt(0) == "0" && this._input.text.length == 1) 
            {
                this._value = parseInt(this._input.text);
            }
            return;
        }

        public /* override */ update(arg1: Object, ... rest): void
        {
            this._data = arg1;
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this._input.text = this._value.toString();
            if (Cache.instance.dominionBea.auctionCityInfo) 
            {
                this._lowPriceTxt.text = Cache.instance.dominionBea.auctionCityInfo.lowPrice.toString();
            }
            return;
        }

        /* internal */ /* var */_infoTxt: GTextFiled;

        /* internal */ /* var */_input: GTextInput;

        /* internal */ /* var */_confirmBtn: GButton;

        /* internal */ /* var */_cancleBtn: GButton;

        /* internal */ /* var */_value: int=0;

        /* internal */ /* var */_data: Object;

        /* internal */ /* var */_lowPriceTxt: GTextFiled;
    }
